package com.demo.entity.response;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@ControllerAdvice
@Slf4j
@Order(1)
public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
    public RestResponseEntityExceptionHandler() {
        super();
    }

    /**
     * 用来处理访问404异常，也就是后台不存在的访问路径
     */
//    @Override
//    protected ResponseEntity<Object> handleExceptionInternal(Exception ex, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
//        log.error(ex.getMessage(),ex);
//        //进行异常包装，主要针对出现404后，继承ResponseBodyAdvice后无法处理的问题
//        return new ResponseEntity<>(Result.error(status.value(),ex.getMessage()), headers, status);
//    }
}
